added "max-child-expand" style property which limits the space taken by
authorMichael Natterer <mitch@imendio.com>
Tue, 16 May 2006 13:51:30 +0000 (13:51 +0000)
committerMichael Natterer <mitch@src.gnome.org>
Tue, 16 May 2006 13:51:30 +0000 (13:51 +0000)
2006-05-16  Michael Natterer  <mitch@imendio.com>

* gtk/gtktoolbar.c: added "max-child-expand" style property which
limits the space taken by expanding tool items. Fixes bug #340722.

ChangeLog
ChangeLog.pre-2-10
gtk/gtktoolbar.c

index 33be26c1061dbfba77cbbdaa890d121e220b65c2..71512ccace22e8015bb681ff6c57de1a8c06e685 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-05-16  Michael Natterer  <mitch@imendio.com>
+
+       * gtk/gtktoolbar.c: added "max-child-expand" style property which
+       limits the space taken by expanding tool items. Fixes bug #340722.
+
 2006-05-16  Kristian Rietveld  <kris@imendio.com>
 
        * gtk/gtkpathbar.c (gtk_path_bar_dispose): cancel all pending handles
index 33be26c1061dbfba77cbbdaa890d121e220b65c2..71512ccace22e8015bb681ff6c57de1a8c06e685 100644 (file)
@@ -1,3 +1,8 @@
+2006-05-16  Michael Natterer  <mitch@imendio.com>
+
+       * gtk/gtktoolbar.c: added "max-child-expand" style property which
+       limits the space taken by expanding tool items. Fixes bug #340722.
+
 2006-05-16  Kristian Rietveld  <kris@imendio.com>
 
        * gtk/gtkpathbar.c (gtk_path_bar_dispose): cancel all pending handles
index 5fea5c8c8bed88f03ad10e0dca9767a76f73db5b..7f384d98284dc5e5c38a95dbbb8c7dc8721955bd 100644 (file)
@@ -57,7 +57,7 @@
 
 typedef struct _ToolbarContent ToolbarContent;
 
-#define DEFAULT_IPADDING 0
+#define DEFAULT_IPADDING    0
 
 #define DEFAULT_SPACE_SIZE  12
 #define DEFAULT_SPACE_STYLE GTK_TOOLBAR_SPACE_LINE
@@ -233,6 +233,7 @@ static gboolean   gtk_toolbar_check_old_api        (GtkToolbar          *toolbar
 
 static GtkReliefStyle       get_button_relief    (GtkToolbar *toolbar);
 static gint                 get_internal_padding (GtkToolbar *toolbar);
+static gint                 get_max_child_expand (GtkToolbar *toolbar);
 static GtkShadowType        get_shadow_type      (GtkToolbar *toolbar);
 static gint                 get_space_size       (GtkToolbar *toolbar);
 static GtkToolbarSpaceStyle get_space_style      (GtkToolbar *toolbar);
@@ -591,7 +592,16 @@ gtk_toolbar_class_init (GtkToolbarClass *klass)
                                                             G_MAXINT,
                                                              DEFAULT_IPADDING,
                                                              GTK_PARAM_READABLE));
-  
+
+  gtk_widget_class_install_style_property (widget_class,
+                                           g_param_spec_int ("max-child-expand",
+                                                             P_("Maximum toolbar item spacing"),
+                                                             P_("Maximum space between the toolbar items."),
+                                                             0,
+                                                             G_MAXINT,
+                                                             G_MAXINT,
+                                                             GTK_PARAM_READABLE));
+
   gtk_widget_class_install_style_property (widget_class,
                                           g_param_spec_enum ("space-style",
                                                              P_("Space style"),
@@ -1596,10 +1606,14 @@ gtk_toolbar_size_allocate (GtkWidget     *widget,
          
          if (toolbar_content_get_expand (content) && new_states[i] == NORMAL)
            {
+              gint mexpand = get_max_child_expand (toolbar);
              gint extra = size / n_expand_items;
              if (size % n_expand_items != 0)
                extra++;
-             
+
+              if (extra > mexpand)
+                extra = mexpand;
+
              allocations[i].width += extra;
              size -= extra;
              n_expand_items--;
@@ -4751,6 +4765,17 @@ get_internal_padding (GtkToolbar *toolbar)
   return ipadding;
 }
 
+static gint
+get_max_child_expand (GtkToolbar *toolbar)
+{
+  gint mexpand = G_MAXINT;
+
+  gtk_widget_style_get (GTK_WIDGET (toolbar),
+                        "max-child-expand", &mexpand,
+                        NULL);
+  return mexpand;
+}
+
 static GtkShadowType
 get_shadow_type (GtkToolbar *toolbar)
 {